/*
Sam Snyder
CS362
Assignment 3
cardtest4.c

This is a test of the smithy card*-----------------------------------------------------------------------
 * Include the following lines in your makefile:
 *
 * cardtest4: cardtest4.c dominion.o rngs.o
 *      gcc -o cardtest4 -g  cardtest4.c dominion.o rngs.o $(CFLAGS)
 * -----------------------------------------------------------------------
 */

#include <math.h>
#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
#include <time.h>
#include <stdlib.h>



// set NOISY_TEST to 0 to remove printfs from output
#define NOISY_TEST 1

 int main() {
 	int r, preHandCount, preActionCount, preScore, seed, choice1, choice2, choice3, handPos, bonus;
 	struct gameState G;
 	int k[10] = {curse, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};
 	if (NOISY_TEST == 1)
 		printf("Testing great_hall card\n\n");
	srand(time(NULL));
	seed = rand();

	r = initializeGame(MAX_PLAYERS, k, seed, &G);

	preHandCount = G.handCount[0];
	preActionCount = G.numActions;
	preScore = scoreFor(0, &G);

	if (NOISY_TEST == 1)
	printf("Pre: hand count %d, actions %d, score %d\n",G.handCount[0], G.numActions, scoreFor(0, &G));
	buyCard(great_hall, &G);
 	cardEffect( great_hall, choice1, choice2,  choice3, &G, 0, &bonus);
 	
	if (NOISY_TEST == 1)
	printf("Post: hand count %d, actions %d, score %d\n\n",G.handCount[0], G.numActions, scoreFor(0, &G));
 	
 	//check if hand is correct size
	if (NOISY_TEST == 1)
 	printf("Testing hand count\n"); 		
 	assert(G.handCount[0] == preHandCount); //-1 (played), +1 (draw)

 	//Check actions
 	if (NOISY_TEST == 1)
 	printf("Testing action count\n"); 		
 	assert(G.numActions == (preActionCount + 1));//+1 actions

	//Check score
 	if (NOISY_TEST == 1)
 	printf("Testing score\n"); 		
 	if((preScore + 1) != (scoreFor(0, &G) ))//+1 score
 	{
 		printf("Error: score should be %d; score is %d\n", (preScore + 1), (scoreFor(0, &G)));	
 	}


 	//if (NOISY_TEST == 1)
 	//	printf("Tests passed");
 	return 0;
 }